<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('融资管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>融资名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>经办人：</label>
                                <input type="text" name="operator"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:finance:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:finance:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:finance:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:finance:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:finance:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:finance:remove')}]];
        var prefix = ctx + "system/finance";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                payUrl: prefix + "/pay/{id}",
                shiftUrl: prefix + "/shift/{id}",
                modalName: "融资管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'name',
                    title: '融资名称'
                },
                {
                    field: 'total',
                    title: '融资总金额'
                },
                {
                    field: 'payTotal',
                    title: '项目支付总金额',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a href="javascript:void(0)" onclick="payTotal(\'' + row.id + '\')">'+row.payTotal+'</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'shiftTotal',
                    title: '转移至资金总金额',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a href="javascript:void(0)" onclick="shiftTotal(\'' + row.id + '\')">'+row.shiftTotal+'</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'operator',
                    title: '经办人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        // 分期管理 全屏
        function payTotal(id) {
            table.set();
            var url = "/404.html";
            if ($.common.isNotEmpty(id)) {
                url = table.options.payUrl.replace("{id}", id);
            } else {
                if(table.options.type == table_type.bootstrapTreeTable) {
                    var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0];
                    if ($.common.isEmpty(row)) {
                        $.modal.alertWarning("请至少选择一条记录");
                        return;
                    }
                    url = table.options.payUrl.replace("{id}", row[table.options.uniqueId]);
                } else {
                    var row = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
                    url = table.options.payUrl.replace("{id}", row);
                }
            }
            $.modal.openFull("支付管理", url);
        }
        // 分期管理 全屏
        function shiftTotal(id) {
            table.set();
            var url = "/404.html";
            if ($.common.isNotEmpty(id)) {
                url = table.options.shiftUrl.replace("{id}", id);
            } else {
                if(table.options.type == table_type.bootstrapTreeTable) {
                    var row = $("#" + table.options.id).bootstrapTreeTable('getSelections')[0];
                    if ($.common.isEmpty(row)) {
                        $.modal.alertWarning("请至少选择一条记录");
                        return;
                    }
                    url = table.options.shiftUrl.replace("{id}", row[table.options.uniqueId]);
                } else {
                    var row = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
                    url = table.options.shiftUrl.replace("{id}", row);
                }
            }
            $.modal.openFull("转移管理", url);
        }
    </script>
</body>
</html>